package com.example.zsf.adapter;

import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.zsf.R;
import com.orhanobut.logger.Logger;

import java.util.List;

public class DialogSelectListAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    public DialogSelectListAdapter(int layoutResId, List<String> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, String s) {
        CheckBox checkBox = baseViewHolder.getView(R.id.checkBox2);
        checkBox.setText(s);
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                OnItemChildClickListener onItemChildClickListener = getOnItemChildClickListener();
                if (onItemChildClickListener != null) {
                    onItemChildClickListener.onItemChildClick(DialogSelectListAdapter.this, checkBox, baseViewHolder.getAdapterPosition());
                }
            }
        });


    }
}
